import { customError, post } from '..'
import { UserResponse, ReturnType, WalletInfo, WithDraw, WithDrawRecord, WithDrawInfo } from '../interface'
import { URL_USER_INFO, URL_WALLET_WITHDRAW, URL_WALLET_WITHDRAW_INFO, URL_WALLET_WITHDRAW_LIST } from '../base/url'

export const wallet = async (): Promise<ReturnType<WalletInfo | undefined>> => {
    try {
        const result = await post<UserResponse>(URL_USER_INFO)
        return result
    } catch (error: any) {
        return customError(error)
    }
}

export const withdraw = async (params: WithDraw): Promise<ReturnType<undefined>> => {
    try {
        return await post(URL_WALLET_WITHDRAW, params)
    } catch (error: any) {
        return customError(error)
    }
}

export const withdrawInfo = async (): Promise<ReturnType<undefined | WithDrawInfo>> => {
    try {
        return await post(URL_WALLET_WITHDRAW_INFO)
    } catch (error: any) {
        return customError(error)
    }
}

export const withdrawList = async (): Promise<ReturnType<undefined | Array<WithDrawRecord>>> => {
    try {
        return await post(URL_WALLET_WITHDRAW_LIST)
    } catch (error: any) {
        return customError(error)
    }
}